<template>
  <dtDialog
    title="查看权限维护"
    :visible.sync="dialogVisible"
    @closeDialog="handleCancel"
    @comfirmBtn="onSubmit()"
  >
    <div class="table-container table-fullscreen">
      <div class="table-opt-container dialog-filter-flex">
        <el-form ref="filterFormRef" :inline="true" :model="queryParams">
          <el-form-item label="姓名" prop="name">
            <el-input v-model.trim="queryParams.name" style="width:200px;" maxlength="30" />
          </el-form-item>
        </el-form>
        <el-button type="primary" @click="handleFilter">搜索</el-button>
      </div>
      <dt-table
        v-if="dialogVisible"
        v-loading="loading"
        :table-opts="tableOpts"
        :is-show-column="false"
        :pagination-data="{
          total: total,
          queryParams: queryParams,
        }"
        @handleSelectionChange="handleSelection"
        @pagination="getList"
      />
    </div>
  </dtDialog>
</template>

<script>
import { getByGroupIdToUserId } from '@/api/videoFusion/monitorGroup'

export default {
  data() {
    return {
      queryParams: {
        name: '',
        pageNo: 1,
        pageSize: 10
      },
      total: 0,
      loading: false,
      tableOpts: {
        configPagination: '1',
        rowKey: 'id',
        firstTableCol: {
          select: true,
          width: 70,
          fit: true
        },
        indexTableCol: {
          label: '序号',
          width: 70,
          fit: true
        },
        tableCol: [
          {
            prop: 'appName',
            label: '姓名',
            show: true
          },
          {
            prop: 'sex',
            label: '性别',
            show: true,
            formatter: (row) => {
              return row.sex === 1 ? '女' : '男'
            }
          },
          {
            prop: 'company',
            label: '所属组织',
            show: true
          }
        ],
        tableData: [{}]
      },
      dialogVisible: false,
      selectList: [],
      groupId: ''
    }
  },
  methods: {
    handleCancel() {
      this.queryParams = {
        name: '',
        pageNo: 1,
        pageSize: 10
      }
    },
    open(data) {
      this.groupId = data.id
      this.dialogVisible = true
      this.getList()
    },
    // 搜索
    handleFilter() {
      this.getList()
    },
    // 重置
    handleReset() {
      // this.$refs.filterFormRef.resetFields('filterForm')
      this.handleFilter()
    },
    getList() {
      getByGroupIdToUserId(this.groupId)
    },
    handleSelection(selection) {
      this.selectList = selection
    },
    onSubmit() {
      if (this.selectList.length > 0) {
        // 提交
      } else {
        this.$dtModal.msgWarning('请至少选择一位业务系统管理人员')
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.dialog-filter-flex {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  button {
    margin-bottom: 24px;
  }
}
</style>
